package com.pomelo.pm;

public abstract class Shape {
    // 需求 要求
    abstract double calculateArea(double a1, double a2);

    String displayShape() {
        return "Shape";
    }
}

class Circle extends Shape {

    @Override
    double calculateArea(double a1, double a2) {
        return Math.PI * a1 * a2;
    }

    String displayShape() {
        return "Circle";
    }
}

class Rectangle extends Shape {

    @Override
    double calculateArea(double a1, double a2) {
        return a1 * a2;
    }

    String displayShape() {
        return "Rectangle";
    }
}

class Triangle extends Shape {

    @Override
    double calculateArea(double a1, double a2) {
        return 1.0 / 2 * a1 * a2;
    }

    String displayShape() {
        return "Triangle";
    }
}


class Test02 {
    public static void main(String[] args) {
        Shape s1 = new Circle();
        System.out.println(s1.displayShape());
        System.out.println(s1.calculateArea(12, 12));
        s1 = new Rectangle();
        System.out.println(s1.displayShape());
        System.out.println(s1.calculateArea(24, 2));
        s1 = new Triangle();
        System.out.println(s1.displayShape());
        System.out.println(s1.calculateArea(12, 5));
    }
}